﻿mini.ux.GridWindow = function() {
	mini.ux.GridWindow.superclass.constructor.call(this);
	this.initControls();
}
mini.extend(mini.ux.GridWindow, mini.ux.Window, {
	title : "用户管理",
	showToolbar : true,
	bodyStyle : "padding:0",

	width : 550,
	height : 300,
	minWidth : 450,
	minHeight : 200,

	dataUrl : __ctxPath + "/system/userlist.do",

	initControls : function() {
		var toolbarEl = this.getToolbarEl();
		var footerEl = this.getFooterEl();
		var bodyEl = this.getBodyEl();

		this.grid = new mini.DataGrid();
		new mini.Button({})
		// toolbar
		var topHtml = '<div style="padding:5px;">'
				+ '<a name="add" class="mini-button" href="javascript:'
				+ this.newRow() + '">增加</a> '
				+ '<a name="edit" class="mini-button">修改</a> '
				+ '<a name="remove" class="mini-button">删除</a> ' + '</div>';
		jQuery(toolbarEl).append(topHtml);

		mini.parse(this.el);

		// body
		this.grid.set({
			multiSelect : this.multiSelect,
			style : "width: 100%;height: 100%;",
			borderStyle : "border:0",
			columns : [ {
				type : "checkcolumn",
				header : "#"
			},
			// { type: "indexcolumn", header: "#", headerAlign: "center" },
			{
				header : "帐号",
				field : "userName"
			}, {
				header : "姓名",
				field : "lastName"
			}, {
				header : "管理",
				field : "userId",
				renderer : function(e) {
					//alert(e.field.toString()); e.serder;e.column;e.rowIndex;e.value;
					return '<a class="mini-button" plain="true" iconCls="icon-add" onclick="onClick">删除</a>';
				}
			} ]
		});
		this.grid.setUrl(this.dataUrl);
		this.grid.render(bodyEl);

		this.grid.load();
		// this.newRow();
	},
	newRow : function() {
		var row = {};
		this.grid.addRow(row, 0);

		this.grid.cancelEdit();
		this.grid.beginEditRow(row);
	}
});
mini.regClass(mini.ux.GridWindow, "ux.gridwindow");
